/**
 * 获取 DOM 的 宽高
 * @param el HTMLElement
 * @returns {number} {width, height}
 */
export const getDOMSize = (el: HTMLElement | null = null) => ({ width: el?.offsetWidth ?? 0, height: el?.offsetHeight ?? 0 });

/**
 * 获取 DOM 的 位置信息
 * @param el HTMLElement
 * @returns {number} { bottom, height, left, right, top, width, x, y }
 */
export const getDOMPosition = (el: HTMLElement | null = null) => {
    const { bottom = 0,
        height = 0,
        left = 0,
        right = 0,
        top = 0,
        width = 0,
        x = 0,
        y = 0 } = el?.getBoundingClientRect() ?? {}
    return {
        bottom,
        height,
        left,
        right,
        top,
        width,
        x,
        y
    };
};
// export const getDOMPosition = (el: HTMLElement | null = null) => ({ x: el?.offsetLeft ?? 0, y: el?.offsetTop ?? 0 });